<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="container">
<div class="row">
<h2>Toggle Dark/Light Mode</h2>
<p>Click the button to toggle between dark and light mode for this page.</p>
<a onclick="myFunction()">
<i onclick="myFunction2(this)" class="fa fa-sun-o"></i>
</a>
</div>
</div>
function myFunction() {
var element = document.body;
element.classList.toggle("dark-mode");
element.classList.toggle("dark-mode h2");
}
function myFunction2(x) {
x.classList.toggle("fa-moon-o");
}